package com.net.flyWeight;

import java.util.HashMap;
import java.util.Map;

public class Coffee 
{
  private String coffeeType;
  
  public static Map<String, Coffee> map = new HashMap<String, Coffee>();
  
  public Coffee(String coffeeType)
  {
	  this.coffeeType = coffeeType;
  }
  
  public static Coffee getCoffee(String coffeeType)
  {
	  if(map.containsKey(coffeeType))
	  {
		  return map.get(coffeeType);
	  }
	  
	  else
	  {
		  Coffee coffee = new Coffee(coffeeType);
		  map.put(coffeeType, coffee);
		  return coffee;
	  }
  }
  
	
}
